<template>
  <div class="report_config">
    <a-card class="title_report">
      <a-steps :current="current">
        <a-step v-for="item in steps" :key="item.title" :title="item.title" />
      </a-steps>
    </a-card>
    <a-card class="content_report">
      <div class="steps-content" style="padding: 12px 12px 0px 12px; flex: 1;">
        <Ds v-if="current == 0" ref="dataset" />
        <Filters v-if="current == 1" />
        <Echarts v-if="current == 2" />
      </div>
      <div class="steps-action">
        <a-button v-if="current > 0" style="margin-right: 8px;" @click="prev">
          上一步
        </a-button>
        <a-button v-if="current < steps.length - 1" type="primary" @click="next">
          下一步
        </a-button>
        <a-button
          v-if="current == steps.length - 1"
          type="primary"
          @click="onSaveReport"
        >
          保存
        </a-button>
        <a-button @click="$router.push({ name: 'ReportList' })"  style="margin-left: 8px; margin-right: 8px;">
          取消
        </a-button>
      </div>
    </a-card>
    
  </div>
</template>

<script>
import Basic from './reportConfig/basic.vue'
import Ds from './reportConfig/ds.vue'
import Filters from './reportConfig/filter.vue'
import Echarts from './reportConfig/echarts.vue'
import { mapActions, mapMutations, mapState } from 'vuex'
  export default {
    components: {
      Basic,
      Ds,
      Filters,
      Echarts
    },
    data () {
      return {
        current: 0,
        steps: [
          {
            title: '选择数据集',
            titleName: '数据集列表'
          },
          {
            title: '筛选区',
            titleName: '筛选条件列表'
          },
          {
            title: '图表',
            titleName: '图表布局'
          }
        ],
        form: {
          name: '',
          remark: '',
        },
        isRules: false
      }
    },
    mounted() {
      if (this.$route.params.report && this.$route.params.report.id) {
        // 修改
        this.$route.meta.title = '配置报表'
        this.SET_REPORT({...this.$route.params.report})
        this.form = {...this.$route.params.report}
      } else {
        // 新增
        this.$route.meta.title = '配置报表'
      }
    },
    computed: {
      ...mapState('custom', ['report'])
    },
    methods: {
      ...mapMutations('custom', ['SET_REPORT', 'SET_ADD_DS_LIST']),
      ...mapActions('custom',['setReport', 'getReportId', 'updateReport']),
      next () {
        this.current++
      },
      prev () {
        this.current--;
      },
      onSaveReport () {
        this.$router.push({path:'/system/report'})
      }
    }
  }
</script>

<style scoped>
.report_config{
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.report_title{
  margin-bottom: 20px;
}

.report_title span {
  display: block;
  float: left;
  margin-bottom: 0;
  padding-right: 12px;
  color: rgba(0,0,0,.85);
  font-weight: 600;
  font-size: 20px;
  line-height: 32px;
}

.report_config>>>.ant-card-body {
  padding: 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.ant-card.ant-card-bordered {
  display: flex;
  flex-direction: column;
  margin-bottom: 10px;
}

.content_report.ant-card.ant-card-bordered {
  height: 100%;
}

.title_report {
  padding: 20px;
}

.content_report {
  flex: 1;
}

.steps-action {
  margin-top: 24px;
  margin-bottom: 12px;
  margin-left: 12px;
}

</style>